﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Utility.Config
{
    /// <summary>
    /// 读取WebConfig值
    /// </summary>
    public class ConfigHelper
    {
        /// <summary>
        /// 默认数据条数
        /// </summary>
        public static int DefaultPageSize = 10;
        /// <summary>
        /// 系统首页地址
        /// </summary>
        public static string WebHomeUrl = string.Empty;
        /// <summary>
        /// 系统标题名称
        /// </summary>
        public static string SystemTitle = string.Empty;
        /// <summary>
        /// 允许发送的IP地址
        /// </summary>
        public static string strAllowClientIP = string.Empty;
        /// <summary>
        /// 系统Web域名
        /// </summary>
        public static string WebDomain = string.Empty;
        /// <summary>
        /// 默认管理员帐号，
        /// </summary>
        public static string strAdmin_UserName = string.Empty;

        /// <summary>
        /// 初始化WebConfig文件中的项
        /// </summary>
        public static void SetConfig()
        {
            strAdmin_UserName = GetConfigAppSetting("Admin_UserName");
            SystemTitle = GetConfigAppSetting("SystemTitle");
            DefaultPageSize = GetConfigAppSetting("DefaultPageSize").ToSafeInt();
            WebHomeUrl = GetConfigAppSetting("WebHomeAddress");
            strAllowClientIP = GetConfigAppSetting("AllowClientIP");
            WebDomain = GetConfigAppSetting("WebDomain");
        }
        public static string GetConfigAppSetting(string strName)
        {
            return ConfigurationManager.AppSettings[strName].ToSafeString();
        }
    }
}
